package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Permission;
import cn.wolfcode.mapper.PermissionMapper;
import cn.wolfcode.query.QueryObject;
import cn.wolfcode.service.IPermissionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionServiceImpl implements IPermissionService {

    @Autowired
    private PermissionMapper mapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Permission record) {
        return mapper.insert(record);
    }

    @Override
    public Permission selectByPrimaryKey(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Permission> selectAll() {
        return mapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Permission record) {
        return mapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Permission> selectByRoleId(Long id) {
        return mapper.selectByRoleId(id);
    }

    @Override
    public PageInfo<Permission> listpage(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Permission> list = mapper.list(qo);
        return new PageInfo<Permission>(list);
    }

    @Override
    public List<String> selectPermissionByEmployeeId(Long id) {
        return mapper.selectPermissionByEmployeeId(id);
    }

    @Override
    public List<String> selectPermissionExpression() {
        return mapper.selectPermissionExpression();
    }
}
